


<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

    <title>Solvers &#8212; CVX Users&#39; Guide</title>
    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="_static/cloud.css" />
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Noticia+Text:400,i,b,bi|Open+Sans:400,i,b,bi|Roboto+Mono:400,i,b,bi&amp;display=swap" type="text/css" />
    
    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
    <script src="_static/doctools.js"></script>
    <script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

    
    
     
        <script src="_static/jquery.cookie.js"></script>
    

    
     
        <script src="_static/cloud.base.js"></script>
    

    
     
        <script src="_static/cloud.js"></script>
    

    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Reference guide" href="funcref.html" />
    <link rel="prev" title="Geometric programming mode" href="gp.html" /> 
        <meta name="viewport" content="width=device-width, initial-scale=1">
  </head><body>
    <div class="relbar-top">
        
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="funcref.html" title="Reference guide"
             accesskey="N">next</a> &nbsp; &nbsp;</li>
        <li class="right" >
          <a href="gp.html" title="Geometric programming mode"
             accesskey="P">previous</a> &nbsp; &nbsp;</li>
    <li><a href="index.html">CVX Users&#39; Guide</a> &#187;</li>

        <li class="nav-item nav-item-this"><a href="">Solvers</a></li> 
      </ul>
    </div>
    </div>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="solvers">
<span id="id1"></span><h1>Solvers<a class="headerlink" href="#solvers" title="Permalink to this heading">¶</a></h1>
<section id="supported-solvers">
<span id="id2"></span><h2>Supported solvers<a class="headerlink" href="#supported-solvers" title="Permalink to this heading">¶</a></h2>
<p>This version of CVX supports four solvers, each with different capabilities:</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Solver name</p></th>
<th class="head"><p>LP</p></th>
<th class="head"><p>QP</p></th>
<th class="head"><p>SOCP</p></th>
<th class="head"><p>SDP</p></th>
<th class="head"><p>GP</p></th>
<th class="head"><p>Integer</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><a class="reference external" href="http://sedumi.ie.lehigh.edu">SeDuMi</a></p></td>
<td><p>Y</p></td>
<td><p>Y</p></td>
<td><p>Y</p></td>
<td><p>Y</p></td>
<td><p>E</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference external" href="http://www.math.nus.edu.sg/~mattohkc/sdpt3.html">SDPT3</a></p></td>
<td><p>Y</p></td>
<td><p>Y</p></td>
<td><p>Y</p></td>
<td><p>Y</p></td>
<td><p>E</p></td>
<td><p>N</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference external" href="http://gurobi.com">Gurobi</a></p></td>
<td><p>Y</p></td>
<td><p>Y</p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
<td><p>N</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference external" href="http://mosek.com">MOSEK</a></p></td>
<td><p>Y</p></td>
<td><p>Y</p></td>
<td><p>Y</p></td>
<td><p>Y</p></td>
<td><p>Y</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference external" href="http://www.gnu.org/software/glpk/">GLPK</a></p></td>
<td><p>Y</p></td>
<td><p>N</p></td>
<td><p>N</p></td>
<td><p>N</p></td>
<td><p>N</p></td>
<td><p>Y</p></td>
</tr>
</tbody>
</table>
<p>(key: Y = Yes, N = No, E = Experimental)</p>
<p>Each solver has different capabilities and different levels of performance. For instance,
SeDuMi <a class="reference internal" href="credits.html#stu99" id="id3"><span>[Stu99]</span></a>, SDPT3 <a class="reference internal" href="credits.html#ttt03" id="id4"><span>[TTT03]</span></a>, and MOSEK support all of the continuous (non-integer) models
that CVX itself supports, while Gurobi is more limited, in that it does not support semidefinite
constraints; and GLPK is limited even further. On the other hand, Gurobi, GLPK, and
MOSEK support integer consraints, while SeDuMi and SDPT3 do not.</p>
<p>SeDuMi and SDPT3 are included with the standard CVX distribution, so you do not need
to download an additional solver to start using CVX. We have also entered into contractual
arrangements with the developers of Gurobi and MOSEK that allow us to ship their binaries
with CVX as well, but using those solvers requires a CVX Professional license. Due to
license differences, we are <em>not</em> able to supply GLPK with CVX. However,</p>
<p>If you are having difficulty with one solver, <em>please try another</em>. No one solver performs
better than the others on <em>every</em> model CVX can generate—including commercial solvers.
That said, if you encounter a problem that one solver can handle well and another
cannot, please send us a bug report (see <a class="reference internal" href="support.html#support"><span class="std std-ref">Support</span></a>) and we will forward the
results to the solver’s authors.</p>
<p>We have created special sections in this user guide for using Gurobi and MOSEK with CVX:</p>
<ul class="simple">
<li><p>Gurobi: <a class="reference internal" href="gurobi.html#gurobi"><span class="std std-ref">Using Gurobi with CVX</span></a></p></li>
<li><p>Mosek:  <a class="reference internal" href="mosek.html#mosek"><span class="std std-ref">Using MOSEK with CVX</span></a></p></li>
</ul>
<p>Support for GLPK should be considered experimental.</p>
</section>
<section id="selecting-a-solver">
<span id="solver-selection"></span><h2>Selecting a solver<a class="headerlink" href="#selecting-a-solver" title="Permalink to this heading">¶</a></h2>
<p>The default solver is currently SDPT3. We have found that SeDuMi is faster for most
problems, but unfortunately not as reliable. None of the solvers are perfect, however,
and you may find for your application that another solver is preferred.</p>
<p>To see which solver is currently selected, simply type</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cvx_solver
</pre></div>
</div>
<p>To change the current solver, simply follow the <code class="docutils literal notranslate"><span class="pre">cvx_solver</span></code> with the name of your
chosen solver. For example, to select SeDuMi, type</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cvx_solver sedumi
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">cvx_solver</span></code> command is case insensitive, so <code class="docutils literal notranslate"><span class="pre">cvx_solver</span> <span class="pre">SeDuMi</span></code>
will work just fine as well.</p>
<p>If you issue this command inside a model—that is, between <code class="docutils literal notranslate"><span class="pre">cvx_begin</span></code> and
<code class="docutils literal notranslate"><span class="pre">cvx_end</span></code> it will change the solver <em>only</em> for that model; the next model will
use the previous choice. If, only the other hand, you issue a <code class="docutils literal notranslate"><span class="pre">cvx_solver</span></code> command
<em>outside</em> of a model, it will change the solver used for the remainder of your Matlab
session (or until you change it again).</p>
<p>If you would like to change the default solver <em>permanently</em>—that is, so that it remains
the default even if you quit and re-start Matlab—then make sure it is set properly,
and then issue the command</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cvx_save_prefs
</pre></div>
</div>
<p>This command saves not only your solver choice, but also your settings for <code class="docutils literal notranslate"><span class="pre">cvx_expert</span></code>,
<code class="docutils literal notranslate"><span class="pre">cvx_power_warning</span></code>, and <code class="docutils literal notranslate"><span class="pre">cvx_precision</span></code> as well.</p>
</section>
<section id="controlling-screen-output">
<span id="solver-output"></span><h2>Controlling screen output<a class="headerlink" href="#controlling-screen-output" title="Permalink to this heading">¶</a></h2>
<p>Once you gain confidence in using CVX and start incorporating it
into your larger algorithms and programs, you are likely going to want
to silence the messages it delivers to the screen. To do so, simply add
the <code class="docutils literal notranslate"><span class="pre">quiet</span></code> keyword to the <code class="docutils literal notranslate"><span class="pre">cvx_begin</span></code> command; that is,</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cvx_begin quiet
    ...
cvx_end
</pre></div>
</div>
<p>Previous versions of CVX utilized a separate <code class="docutils literal notranslate"><span class="pre">cvx_quiet</span></code> command
and that command is still available in this version as well, if you
prefer it. Entering <code class="docutils literal notranslate"><span class="pre">cvx_quiet</span> <span class="pre">true</span></code> suppresses screen output from the
solver, while entering <code class="docutils literal notranslate"><span class="pre">cvx_quiet</span> <span class="pre">false</span></code> restores the screen output.
If you enter these commands within a model—that is, between
<code class="docutils literal notranslate"><span class="pre">cvx_begin</span></code> and <code class="docutils literal notranslate"><span class="pre">cvx_end</span></code>—it will affect only that model. If you
enter it <em>outside</em> of a model, it will affect all subsequent models.
Entering cvx_quiet with no arguments returns the current setting.</p>
</section>
<section id="interpreting-the-results">
<span id="interpreting"></span><h2>Interpreting the results<a class="headerlink" href="#interpreting-the-results" title="Permalink to this heading">¶</a></h2>
<p>After a complete CVX specification has been entered and the
cvx_end command issued, the solver is called to generate a numerical
result. It proceeds to replace the variables in your model with the
computed numerical values, and creates the variable cvx_optval
containing the value of the objective function. It also summarizes the
result of its efforts in the form of a string named <code class="docutils literal notranslate"><span class="pre">cvx_status</span></code>. The
possible values of <code class="docutils literal notranslate"><span class="pre">cvx_status</span></code> are as follows:</p>
<dl>
<dt><code class="docutils literal notranslate"><span class="pre">Solved</span></code></dt><dd><p>A complementary (primal and dual) solution has been found. The
primal and dual variables are replaced with their computed values,
and the the optimal value of the problem is placed in cvx_optval
(which, by convention, is <span class="math notranslate nohighlight">\(0\)</span> for feasibility problems).</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Unbounded</span></code></dt><dd><p>The solver has determined that the problem is unbounded. The value
of <code class="docutils literal notranslate"><span class="pre">cvx_optval</span></code> is set to <code class="docutils literal notranslate"><span class="pre">-Inf</span></code> for minimizations, and <code class="docutils literal notranslate"><span class="pre">+Inf</span></code>
for maximizations. (Feasibility problems, by construction, never
produce an <code class="docutils literal notranslate"><span class="pre">Unbounded</span></code> status.) The values of any dual variables
are replaced with <code class="docutils literal notranslate"><span class="pre">NaN</span></code>, as the dual problem is in fact
infeasible.</p>
<p>For unbounded problems, CVX stores an <em>unbounded direction</em> into
the problem variables. This is is a <em>direction</em> along which the
feasible set is unbounded, and the optimal value approaches
<span class="math notranslate nohighlight">\(\pm\infty\)</span>. It is important to understand that this value is
very likely <em>not</em> a feasible point. If a feasible point is required,
the problem should be re-solved as a feasibility problem by omitting
the objective. Mathematically speaking, given an unbounded direction
<span class="math notranslate nohighlight">\(v\)</span> and a feasible point <span class="math notranslate nohighlight">\(x\)</span>, <span class="math notranslate nohighlight">\(x+tv\)</span> is feasible
for all <span class="math notranslate nohighlight">\(t\geq0\)</span>, and the objective tends to <span class="math notranslate nohighlight">\(-\infty\)</span>
(for minimizations; <span class="math notranslate nohighlight">\(+\infty\)</span> for maximizations) as
<span class="math notranslate nohighlight">\(t\rightarrow+\infty\)</span> itself.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Infeasible</span></code></dt><dd><p>The problem has been proven to be infeasible through the discovery
of an unbounded direction. The values of the variables are filled
with <code class="docutils literal notranslate"><span class="pre">NaN</span></code>, and the value of <code class="docutils literal notranslate"><span class="pre">cvx_optval</span></code> is set to <code class="docutils literal notranslate"><span class="pre">+Inf</span></code>
for minimizations and feasibility problems, and <code class="docutils literal notranslate"><span class="pre">-Inf</span></code> for
maximizations.</p>
<p>Associated with a provably infeasible problem is an <em>unbounded dual
direction</em>. Appropriate components of this direction are stored in
the dual variables. Similarly to the <code class="docutils literal notranslate"><span class="pre">Unbounded</span></code> case, it is
important to understand that the unbounded dual direction is very
likely not a feasible dual point.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Inaccurate/Solved</span></code>, <code class="docutils literal notranslate"><span class="pre">Inaccurate/Unbounded</span></code>, <code class="docutils literal notranslate"><span class="pre">Inaccurate/Infeasible</span></code></dt><dd><p>These three status values indicate that the solver was unable to
make a determination to within the default numerical tolerance.
However, it determined that the results obtained satisfied a
“relaxed” tolerance leve and therefore may still be suitable for
further use. If this occurs, you should test the validity of the
computed solution before using it in further calculations. See
<a class="reference internal" href="#solver-precision"><span class="std std-ref">Controlling precision</span></a> for a more advanced
discussion of solver tolerances and how to make adjustments.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Suboptimal</span></code></dt><dd><p>This status is possible only for <em>mixed-integer</em> problems. It is
returned when the branching algorithm has discovered at least one
feasible integer solution, but it was unable to continue the search
process to global optimality. This will occur if the solver is
required to terminate due to a time limit or a forced interruption
(for example, if the user types <cite>Ctrl-C</cite>.)</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Failed</span></code></dt><dd><p>The solver failed to make sufficient progress towards a solution,
even to within the “relaxed” tolerance setting. The values of
cvx_optval and primal and dual variables are filled with
<code class="docutils literal notranslate"><span class="pre">NaN</span></code>. This result can occur because of numerical problems
within SeDuMi, often because the problem is particularly “nasty” in
some way (<em>e.g.</em>, a non-zero duality gap).</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">Overdetermined</span></code></dt><dd><p>The presolver has determined that the problem has more equality
constraints than variables, which means that the coefficient matrix
of the equality constraints is singular. In practice, such problems
are often, but not always, infeasible. Unfortunately, solvers
typically cannot handle such problems, so a precise conclusion
cannot be reached. The situations that most commonly produce an
Overdetermined result are discussed in <a class="reference internal" href="advanced.html#overdetermined"><span class="std std-ref">Overdetermined problems</span></a>.</p>
</dd>
</dl>
</section>
<section id="controlling-precision">
<span id="solver-precision"></span><h2>Controlling precision<a class="headerlink" href="#controlling-precision" title="Permalink to this heading">¶</a></h2>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>We consider the modification of solver precision to be an advanced feature, to be
used sparingly, if at all—and only after you have become
comfortable building models in CVX.</p>
</div>
<p>Numerical methods for convex optimization are not exact; they compute
their results to within a predefined numerical precision or tolerance.
Upon solution of your model, the tolerance level the solver has achieved
is returned in the <code class="docutils literal notranslate"><span class="pre">cvx_slvtol</span></code> variable. Attempts to interpret this
tolerance level in any absolute sense are not recommended. For one
thing, each solver computes it differently. For another, it depends
heavily on the considerable transformations that CVX applies to your
model before delivering it to the solver. So while you may find its
value interesting we strongly discourage dependence upon it within your
applications.</p>
<p>The tolerance levels that CVX selects by default have been inherited
from some of the underlying solvers being used, with minor modifications.
CVX actually considers <em>three</em> different tolerance levels
<span class="math notranslate nohighlight">\(\epsilon_{\text{solver}}\leq\epsilon_{\text{standard}}\leq\epsilon_{\text{reduced}}\)</span>
when solving a model:</p>
<ul class="simple">
<li><p>The <em>solver tolerance</em> <span class="math notranslate nohighlight">\(\epsilon_{\text{solver}}\)</span> is the level
requested of the solver. The solver will stop as soon as it achieves
this level, or until no further progress is possible.</p></li>
<li><p>The <em>standard tolerance</em> <span class="math notranslate nohighlight">\(\epsilon_{\text{standard}}\)</span> is the
level at which CVX considers the model solved to full precision.</p></li>
<li><p>The <em>reduced tolerance</em> <span class="math notranslate nohighlight">\(\epsilon_{\text{reduced}}\)</span> is the
level at which CVX considers the model “inaccurately” sovled,
returning a status with the <code class="docutils literal notranslate"><span class="pre">Inaccurate/</span></code> prefix. If this tolerance
cannot be achieved, CVX returns a status of <code class="docutils literal notranslate"><span class="pre">Failed</span></code>, and the
values of the variables should not be considered reliable.</p></li>
</ul>
<p>(See <a class="reference internal" href="#interpreting"><span class="std std-ref">Interpreting the results</span></a> for more information about the
status messages.) Typically,
<span class="math notranslate nohighlight">\(\epsilon_{\text{solver}}=\epsilon_{\text{standard}}\)</span>, but setting
<span class="math notranslate nohighlight">\(\epsilon_{\text{standard}}&lt;\epsilon_{\text{solver}}\)</span> has a useful
interpretation: it allows the solver to search for more accurate
solutions without causing an <code class="docutils literal notranslate"><span class="pre">Inaccurate/</span></code> or <code class="docutils literal notranslate"><span class="pre">Failed</span></code> condition if
it cannot do so. The default values of
<span class="math notranslate nohighlight">\([\epsilon_{\text{solver}},\epsilon_{\text{standard}},\epsilon_{\text{reduced}}]\)</span>
are set to <span class="math notranslate nohighlight">\([ \epsilon^{1/2}, \epsilon^{1/2}, \epsilon^{1/4} ]\)</span>,
where <span class="math notranslate nohighlight">\(\epsilon=2.22\times10^{-16}\)</span> is the machine precision. This
should be quite sufficient for most applications.</p>
<p>If you wish to modify the tolerances, you may do so using the
<code class="docutils literal notranslate"><span class="pre">cvx_precision</span></code> command. There are three ways to invoke this command.
Called with no arguments, it will print the current tolerance levels
to the screen; or if called as a function, it will return those levels
in a 3-element row vector.</p>
<p>Calling <code class="docutils literal notranslate"><span class="pre">cvx_precision</span></code> with a string argument allows you to select
from a set of predefined precision modes:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">cvx_precision</span> <span class="pre">low</span></code>:
<span class="math notranslate nohighlight">\([ \epsilon^{3/8}, \epsilon^{1/4}, \epsilon^{1/4} ]\)</span></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">cvx_precision</span> <span class="pre">medium</span></code>:
<span class="math notranslate nohighlight">\([ \epsilon^{1/2}, \epsilon^{3/8}, \epsilon^{1/4} ]\)</span></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">cvx_precision</span> <span class="pre">default</span></code>:
<span class="math notranslate nohighlight">\([ \epsilon^{1/2}, \epsilon^{1/2}, \epsilon^{1/4} ]\)</span></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">cvx_precision</span> <span class="pre">high</span></code>:
<span class="math notranslate nohighlight">\([ \epsilon^{3/4}, \epsilon^{3/4}, \epsilon^{3/8} ]\)</span></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">cvx_precision</span> <span class="pre">best</span></code>: <span class="math notranslate nohighlight">\([ 0, \epsilon^{1/2}, \epsilon^{1/4} ]\)</span></p></li>
</ul>
<p>In function mode, these calls look like <code class="docutils literal notranslate"><span class="pre">cvx_precision('low')</span></code>, etc.
Note that the <code class="docutils literal notranslate"><span class="pre">best</span></code> precision settings sets the solver target to
zero, which means that the solver continues as long as it can make
progress. It will often be slower than <code class="docutils literal notranslate"><span class="pre">default</span></code>, but it is just as
reliable, and sometimes produces more accurate solutions.</p>
<p>Finally, the <code class="docutils literal notranslate"><span class="pre">cvx_precision</span></code> command can be called with a scalar, a
length-2 vector, or a length-3 vector. If you pass it a scalar, it will
set the solver and standard tolerances to that value, and it will
compute a default reduced precision value for you. Roughly speaking,
that reduced precision will be the square root of the standard
precision, with some bounds imposed to make sure that it stays
reasonable. If you supply two values, the smaller will be used for the
solver and standard tolerances, and the larger for the reduced
tolerance. If you supply three values, their values will be sorted, and
each tolerance will be set separately.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">cvx_precision</span></code> command can be used either <em>within</em> a CVX
model or <em>outside</em> of it; and its behavior differs in each case. If you
call it from within a model, <em>e.g.</em>,</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cvx_begin
    cvx_precision high
    ...
cvx_end
</pre></div>
</div>
<p>then the setting you choose will apply only until <code class="docutils literal notranslate"><span class="pre">cvx_end</span></code> is
reached. If you call it outside a model, <em>e.g.</em>,</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cvx_precision high
cvx_begin
    ...
cvx_end
</pre></div>
</div>
<p>then the setting you choose will apply <em>globally</em>; that is, to any
subsequent models that are created and solved. The local approach should
be preferred in an application where multiple models are constructed and
solved at different levels of precision.</p>
<p>If you call <code class="docutils literal notranslate"><span class="pre">cvx_precision</span></code> in function mode, either with a string or
a numeric value, it will return as its output the <em>previous</em> precision
vector—the same result you would obtain if you called it with no
arguments. This may seem confusing at first, but this is done so that
you can save the previous value in a variable, and restore it at the end
of your calculations; e.g.,</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cvxp = cvx_precision( &#39;high&#39; );
cvx_begin
    ...
cvx_end
cvx_precision( cvxp );
</pre></div>
</div>
<p>This is considered good coding etiquette in a larger application where
multiple CVX models at multiple precision levels may be employed. Of
course, a simpler but equally courteous approach is to call
<code class="docutils literal notranslate"><span class="pre">cvx_precision</span></code> within the CVX model, as described above, so that
its effect lasts only for that model.</p>
</section>
<section id="advanced-solver-settings">
<span id="solver-settings"></span><h2>Advanced solver settings<a class="headerlink" href="#advanced-solver-settings" title="Permalink to this heading">¶</a></h2>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>This is an <strong>advanced topic</strong> for users who have a deep understanding of the
underlying solver they are using, or who have received specific advice from
the solver’s developer for improving performance. Improper use of the
<code class="docutils literal notranslate"><span class="pre">cvx_solver_settings</span></code> command can cause unpredictable results.</p>
</div>
<p>Solvers can be tuned and adjusted in a variety of ways. Solver vendors attempt to select
default settings that will provide good performance across a broad range of
problems. But no solver, and no choice of settings, will perform well for every
possible model. On occasion, it may be worthwhile to give a particular special instructions
to improve its performance for a specific application. Unfortunately, such settings differ
from solver to solver, so there is no way for CVX to provide this ability in a verifiable,
reliable, global fashion.</p>
<p>Nevertheless, using the new <code class="docutils literal notranslate"><span class="pre">cvx_solver_settings</span></code> command, you can customize a solver’s
settings when a specific model demands it. We cannot emphasize enough that this is an
<em>expert</em> feature to be employed by experienced modelers only. Indeed, if you are an
expert, you understand that these warnings are essential:</p>
<ul class="simple">
<li><p>CVX does not check the correctness of the settings you supply. If the solver rejects the
settings, CVX will fail until you change or remove those settings.</p></li>
<li><p>There is no guarantee that altering the settings will improve performance in any
way; indeed, it can make the performance worse.</p></li>
<li><p>CVX Research provides <em>no</em> documentation on the specific settings available for each
solver; you will have to consult the solver’s own documentation for this.</p></li>
<li><p>The settings set here <em>override</em> any default values CVX may have chosen for each solver.
Thus in certain cases, using this feature this may actually confuse CVX and cause it to
misinterpret the results. For this reason, we cannot support all possible
combinations of custom settings.</p></li>
<li><p>Unless you have turned off solver output completely, CVX will warn you if any custom
settings are in effect every time you solve model.</p></li>
</ul>
<p>With this warning out of the way, let us introduce <code class="docutils literal notranslate"><span class="pre">cvx_solver_settings</span></code>. Typing</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cvx_solver_settings
</pre></div>
</div>
<p>at the command prompt provides a listing of the custom settings that have been provided
for the active solver. Custom settings are <em>specific to each solver</em>. Typing</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cvx_solver_settings -all
</pre></div>
</div>
<p>will provide a full list of the custom settings provided for <em>all</em> solvers.</p>
<p>To create a new custom setting for the current solver, use this syntax:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cvx_solver_settings( &#39;{name}&#39;, {value} )
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">{name}</span></code> must be a valid MATLAB variable/field name. <code class="docutils literal notranslate"><span class="pre">{value}</span></code> can be <em>any</em> valid Matlab
object; CVX does not check its value in any way.</p>
<p>To clear all custom settings for the active solver, type</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cvx_solver_settings -clear
</pre></div>
</div>
<p>To clear just a single setting, type</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cvx_solver_settings -clear {&lt;name&gt;}
</pre></div>
</div>
<p>To clear all settings for all solvers, type</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cvx_solver_settings -clearall
</pre></div>
</div>
<p>The settings created by the <code class="docutils literal notranslate"><span class="pre">cvx_solver_settings</span></code> command enjoy the same scope as
<code class="docutils literal notranslate"><span class="pre">cvx_solver</span></code>, <code class="docutils literal notranslate"><span class="pre">cvx_precision</span></code>, and so forth. For instance, if you use this command
<em>within</em> a model—between <code class="docutils literal notranslate"><span class="pre">cvx_begin</span></code> and <code class="docutils literal notranslate"><span class="pre">cvx_end</span></code>—the changes will apply only
to that particular model. If you issue the command <em>outside</em> of a particular model, the
change will persist through the end of the MATLAB session (or until you change it again).
Finally, if you use the <code class="docutils literal notranslate"><span class="pre">cvx_save_prefs</span></code> command, any custom settings you have added
will be saved and restored the next time you start Matlab.</p>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
        <p class="logo"><a href="index.html" title="index">
          <img class="logo" src="_static/cvxrlogo.png" alt="Logo"/>
        </a></p><div class="sphinx-toc sphinxlocaltoc">
    <h3><a href="index.html">Page contents</a></h3>
    <ul>
<li><a class="reference internal" href="#">Solvers</a><ul>
<li><a class="reference internal" href="#supported-solvers">Supported solvers</a></li>
<li><a class="reference internal" href="#selecting-a-solver">Selecting a solver</a></li>
<li><a class="reference internal" href="#controlling-screen-output">Controlling screen output</a></li>
<li><a class="reference internal" href="#interpreting-the-results">Interpreting the results</a></li>
<li><a class="reference internal" href="#controlling-precision">Controlling precision</a></li>
<li><a class="reference internal" href="#advanced-solver-settings">Advanced solver settings</a></li>
</ul>
</li>
</ul>

  </div>
  <div class="sphinxprev">
    <h4>Previous page</h4>
    <p class="topless"><a href="gp.html"
                          title="Previous page">&larr; Geometric programming mode</a></p>
  </div>
  <div class="sphinxnext">
    <h4>Next page</h4>
    <p class="topless"><a href="funcref.html"
                          title="Next page">&rarr; Reference guide</a></p>
  </div>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="_sources/solver.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div><h3>Other links</h3>
<ul class="this-page-menu">
<li><a href="CVX.pdf" target="_blank">Download the PDF</a></li>
<li><a href="http://cvxr.com/cvx">CVX home page</a></li>
</ul>


<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>document.getElementById('searchbox').style.display = "block"</script>
        </div>
      </div>
    
    
        <div class="sidebar-toggle-group no-js">
            
            <button class="sidebar-toggle" id="sidebar-hide" title="Hide the sidebar menu">
                 «
                <span class="show-for-small">hide menu</span>
                
            </button>
            <button class="sidebar-toggle" id="sidebar-show" title="Show the sidebar menu">
                
                <span class="show-for-small">menu</span>
                <span class="hide-for-small">sidebar</span>
                 »
            </button>
        </div>
    
      <div class="clearer"></div>
    </div>
    <div class="relbar-bottom">
        
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="funcref.html" title="Reference guide"
             >next</a> &nbsp; &nbsp;</li>
        <li class="right" >
          <a href="gp.html" title="Geometric programming mode"
             >previous</a> &nbsp; &nbsp;</li>
    <li><a href="index.html">CVX Users&#39; Guide</a> &#187;</li>

        <li class="nav-item nav-item-this"><a href="">Solvers</a></li> 
      </ul>
    </div>
    </div>

    <div class="footer" role="contentinfo">
        &#169; Copyright © 2012, CVX Research, Inc..
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.0.2.
    </div>
    <!-- cloud_sptheme 1.4 -->
  </body>
</html>